package ym.ecrm.core.domain.salesManagement;

import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.hibernate.annotations.Cascade;

import ym.ecrm.core.domain.base.BaseEntity;
import ym.ecrm.core.domain.systemManagement.Organization;

/**
 * 产品分类
 * 
 * @author Princess
 * @version 1.0
 */
@Entity
@Table(name = "t_productionCategory")
public class ProductionCategory extends BaseEntity {

	/**
	 * 类名称
	 */
	private String productionCategoryName;
	
	/**
	 * 产品
	 */
	@OneToMany
	private Set<Production> productions = new HashSet<Production>();

	/**
	 * 父类
	 */
	@ManyToOne(targetEntity = ProductionCategory.class, cascade = {
			CascadeType.PERSIST, CascadeType.MERGE })
	@JoinColumn(name = "parent_id")
	private ProductionCategory parent;

	/**
	 * 子类集合
	 */
	@OneToMany(targetEntity=ProductionCategory.class,
			cascade={CascadeType.PERSIST,CascadeType.MERGE},
			fetch=FetchType.LAZY,
			mappedBy="parent")
	@Cascade(value=org.hibernate.annotations.CascadeType.DELETE)
	private Set<ProductionCategory> childs = new HashSet<ProductionCategory>();

	public String getProductionCategoryName() {
		return productionCategoryName;
	}

	public void setProductionCategoryName(String productionCategoryName) {
		this.productionCategoryName = productionCategoryName;
	}

	public ProductionCategory getParent() {
		return parent;
	}

	public void setParent(ProductionCategory parent) {
		this.parent = parent;
	}

	public Set<ProductionCategory> getChilds() {
		return childs;
	}

	public void setChilds(Set<ProductionCategory> childs) {
		this.childs = childs;
	}

	public Set<Production> getProductions() {
		return productions;
	}

	public void setProductions(Set<Production> productions) {
		this.productions = productions;
	}

}
